package de.thm.exa;

import de.thm.exa.interfaces.TestInterface;
import de.thm.exa.tests.ChainedTest;
import de.thm.exa.tests.CuckooTest;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class HashTest
{
    public static void main(String[] args) throws IOException
    {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        
        int input;
        
        while(true)
        {
            printInput();
            try
            {
                input = Integer.parseInt( reader.readLine() );
            } catch(NumberFormatException e) {
                printError();
                continue;
            }
            
            TestInterface tester;
            switch(input)
            {
                case 0:
                    tester = new CuckooTest();
                    tester.test();
                    reader.close();
                    return;
                case 1:
                    tester = new ChainedTest();
                    tester.test();
                    reader.close();
                    return;
                default:
                    printError();
                    continue;
            }
        }
    }
    
    private static void printInput()
    {
        System.out.println(
                  "Enter a number:\n"
                + "  0: Cuckoo Hashing\n"
                + "  1: Chained Hashing\n");
    }
    
    private static void printError()
    {
        System.out.println("This was not a correct input.");
    }
}
